$(function(){
	provinces('.province',"change",2);
	provinces('#city',"change",3);
	var orgin =$(".orgin").attr("title");
	if(orgin != 'edit'){
		$.ajax({   
		     url:'plantbase/realList.do',   
		     type:'post',   
		     data:{'parentId':0},   
		     async : false, //默认为true 异步   
		     success:function(data){
		    	 $(".province").empty();
		    	 $(".province").append('<option value=0>请选择</option>');
		    	$.each(data.list,function(i,v){
		    		$(".province").append('<option value='+v.id+'>'+v.areaName+'</option>');
		    	});
		    	
		     }
		 });
	}
});
/**
 * v:元素
 * t:1,省份，2,市区,3,县
 */
var provinces = function (v,e,t){
	$(v).on(e,function(){
		var v1_ =$(this);
		var va_=v1_.val();
		if(va_ .length<=0){
			va_ = 0;
		}
		$.ajax({   
		     url:'plantbase/realList.do',   
		     type:'post',   
		     data:{'parentId':va_},   
		     async : false, //默认为true 异步   
		     success:function(data){
		    	 var obj;
		    	 
		    	 if(t == '2'){
		    		 obj = $("#city");
		    	 }else if(t == '3'){
		    		 obj = $("#county");
		    	 }
		    	 obj.empty();
		    	 obj.append('<option value=0>请选择</option>');
			    	$.each(data.list,function(i,v){

			    		obj.append('<option  value='+v.id+'>'+v.areaName+'</option>');

			    	});
		    	
		     }
		 });
	});
}

